<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>图片跟随</title>
    <script src="https://code.jquery.com/jquery-3.6.4.min.js" integrity="sha256-oP6HI9z1XaZNBrJURtCoUT5SUnxFr8s3BzRl+cbzUq8=" crossorigin="anonymous"></script>
    <script>
        $(function () {
            $("img:first").bind("mouseover mouseout mousemove",function (event) {
                if(event.type=="mouseover") $("img:last").show();
                else if(event.type=="mouseout") $("img:last").hide();
                else{
                    $("img:last").offset({
                        top:event.pageX,
                        left:event.pageY
                    });
                }
            });
        });
    </script>
</head>
<body>
        <div align="center"><img src="jp1.jpg" width="400" height="300"></div>
        <img src="jp1.jpg">
</body>
</html>